﻿namespace Pub.Class
{
    using System;

    public class Compress : Disposable
    {
        private readonly ICompress compress;

        public Compress()
        {
            if (this.compress.IsNull())
            {
                this.compress = (ICompress) (WebConfig.GetApp("CompressProviderName") ?? "Pub.Class.SharpZip.Compress,Pub.Class.SharpZip").LoadClass();
            }
        }

        public Compress(string classNameAndAssembly)
        {
            if (this.compress.IsNull())
            {
                this.compress = (ICompress) classNameAndAssembly.IfNullOrEmpty("Pub.Class.SharpZip.Compress,Pub.Class.SharpZip").LoadClass();
            }
        }

        public Compress(string dllFileName, string className)
        {
            if (this.compress.IsNull())
            {
                this.compress = (ICompress) dllFileName.LoadClass(className);
            }
        }

        public Compress Directory(string source, string descZip)
        {
            this.compress.Directory(source, descZip);
            return this;
        }

        public Compress File(string source, string descZip)
        {
            this.compress.File(source, descZip);
            return this;
        }

        public Compress File(string[] source, string descZip)
        {
            this.compress.File(source, descZip);
            return this;
        }

        public Compress File(string source, string descZip, int compressionLevel, int blockSize)
        {
            this.compress.File(source, descZip, compressionLevel, blockSize);
            return this;
        }

        protected override void InternalDispose()
        {
            base.InternalDispose();
        }
    }
}

